<template>
    <div class="body person" v-if="userrefresh">
        <dl class="pr_top">
            <dd><img :src="myimg" alt=""></dd>
            <dt>
                <div><span v-html="userInfo.nikeName"></span><i v-html="userInfo.mobile"></i></div>
                <div><p>{{username}}</p></div>
                <p>ID：{{userInfo.id}}</p>
            </dt>
        </dl>
        <!---->
        <dl class="pr_box pr_box1">
            <dd>
                <div v-html="suerTixian.ktxje"></div>
                <p>账户总额 (元)</p>
            </dd>
            <dt>
                <p @click="tixianNew()">立即提现</p>
            </dt>
        </dl>
        <!---->
        <ul class="pr_box pr_box2">
            <li>
                <p v-html="suerTixian.dsh"></p>
                <div>待审核(元)</div>
            </li>
            <li>
                <p v-html="suerTixian.ytxje"></p>
                <div>已提现(元)</div>
            </li>
        </ul>
        <!---->
        <div class="pr_box3" @click="changepassword()">
            <img class="pr_img1" src="../img/xingxing.png" alt="">
            <span>成为会员</span>
            <img class="pr_img2" src="../img/arrowrig.png" alt="">
        </div>
        <!---->
        <ul class="xinyong">
            <li>
                <p>信用卡推广</p>
                <div class="xing1" @click="turnshare(1)">
                    <h2 style="margin-top: 0.36rem;">信用卡秒下</h2>
                    <h2>额度高</h2>
                </div>
            </li>
            <li>
                <p>贷款推广</p>
                <div class="xing2" @click="turnshare(2)">
                    <h2 style="margin-top: 0.36rem;">单笔返佣</h2>
                    <h2>高达万元</h2>
                </div>
            </li>
        </ul>
        <!---->
        <div class="pr_btn" @click="logout()" style="margin-bottom: 1rem;">退出登录</div>
        <div style="height: 1rem;"></div>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';

    export default {
        name: "person",
        data(){
            return {
                userInfo:{},
                userrefresh:false,
                suerTixian:{},
                myimg: require("../img/morentouxiang.png"),
                username:""
            }
        },
        mounted(){
            this.$store.state.navTabstatu = 0;
            this.getuserinfo();
            this.userTixian();
            this.checkdevice();
            let preHandler = function(e){e.preventDefault();}
            document.addEventListener('touch', preHandler, false);
            // document.body.style.overflow = '';
            //document.removeEventListener('touchmove', this.bodyScroll(),false);
        },
        methods:{
            //检测设备型号
            checkdevice() {
                let idrefresh = sessionStorage.idrefresh;
                if (this.common.checksestom() == "Android") {
                    if (!idrefresh) {
                        sessionStorage.idrefresh = true;
                        console.log("123456789");
                        document.querySelector('html').setAttribute('style', 'overflow:auto');
                        document.querySelector('body').setAttribute('style', 'overflow:auto');
                        document.querySelector('#app').setAttribute('style', 'overflow:auto');
                        console.log(document.querySelector('html'))
                        // location.reload();
                    }
                }
            },
            userTixian(){
                this.axios({
                    method: 'get',
                    url: 'apis/partner/txje',
                    data: {},
                    withCredentials: true,
                    headers: {'token':JSON.parse(localStorage.hhrdata).token},
                }).then((response) => {
                    console.log(response)
                    if(response.data.code==-8){
                        this.common.checkLogin(this);
                    }
                    this.suerTixian = response.data.data;

                }).catch((error) => {
                    console.log(error)
                });
            },
            tixianNew(){
                this.$router.push({path: '/tixian', query: {selected: "2"}})
            },
            turnshare(status){
                if(status=="1"){
                    this.$router.push({path: '/shareXinyongka', query: {selected: "2"}})
                }else{
                    this.$router.push({path: '/shareDaikuan', query: {selected: "2"}})
                }
            },
            logout(){
                this.axios({
                    method: 'get',
                    url: this.common.baseURL+'/logout',
                    data: this.qs.stringify({}),
                    withCredentials: true,
                }).then((response) => {
                    console.log(response)
                    // this.common.loginCheak(this,response.data.code);
                    if(response.data == "logout->success"){
                        // this.common.logout(this);
                        Toast({
                            message: '退出成功，返回登录页',
                            position: 'center',
                            duration: 2000
                        });
                        localStorage.removeItem("hhrdata");
                        setTimeout(() => {
                            this.$router.push('/');
                        }, 2000);
                    }
                }).catch((error) => {
                    console.log(error)
                });
            },
            getuserinfo(){
                this.axios({
                    method: 'get',
                    url: 'apis/partner/userinfo',
                    data: {},
                    withCredentials: true,
                    headers: {'token':JSON.parse(localStorage.hhrdata).token},
                }).then((response) => {
                    console.log(response)
                    if(response.data.code==-8){
                        this.common.checkLogin(this);
                        return
                    }
                    this.userInfo = response.data.data;
                    if(response.data.data.image){
                        this.myimg = response.data.data.image
                    }
                    this.userrefresh = true;


                    let obj = {};
                    obj = response.data.data;
                    obj.token = response.data.message;
                    localStorage.hhrdata = JSON.stringify(obj);


                    switch(response.data.data.level){
                        case "1":
                            this.username = "经纪人";
                            break;
                        case "2":
                            this.username = "会员";
                            break;
                        default:
                            this.username = "普通用户";
                    }

                }).catch((error) => {
                    console.log(error)
                });
            },
            changepassword(){
                this.$router.push({path: '/member', query: {selected: "2"}})
            }
        }
    }
</script>

<style scoped lang="less">
    .navbtmbox{
        display: none;
    }
    .person{
        background:rgba(244,244,244,1);
        .pr_top{
            min-height: 2.4rem;
            background:rgba(38,119,249,1);
            opacity:0.9;
            padding: 0.5rem;
            dd{
                float: left;
                width: 1.8rem;
                height: 1.8rem;
                background:rgba(255,255,255,0.5);
                border-radius:50%;
                img{
                    width: 1.6rem;
                    height: 1.6rem;
                    display: inline-block;
                    margin: 0.1rem;
                    border-radius:50%;
                }
            }
            dt{
                float: left;
                color: #fff;
                margin-left: 0.2rem;
                div{
                    line-height: 0.7rem;
                    height: 0.7rem;
                    span{
                        font-size:0.4rem;
                    }
                    i{
                        font-size:0.32rem;
                        margin-left: 0.3rem;
                    }
                    p{
                        width:1.1rem;
                        height:0.38rem;
                        background:rgba(255,218,70,1);
                        border-radius:0.19rem;
                        font-size:0.22rem;
                        color:rgba(58,131,249,1);
                        text-align: center;
                        line-height: 0.38rem;
                        margin:  0.16rem 0;
                    }
                }
                p{
                    font-size:0.3rem;
                }
            }
        }

        .pr_box{
            width: 6.1rem;
            padding: 0.4rem;
            height: 1.1rem;
            margin: 0.2rem auto 0 auto;
            background: #fff;
        }

        .pr_box1{
            dd{
                float: left;
                div{
                    font-size:0.48rem;
                    font-weight:500;
                    color:rgba(247,98,96,1);
                }
                p{
                    font-size:0.24rem;
                    font-weight:400;
                    color:rgba(187,187,187,1);
                    margin-top: 0.1rem;
                }
            }
            dt{
                float: right;
                p{
                    width:1.6rem;
                    height:0.68rem;
                    background:rgba(38,119,249,1);
                    border-radius:0.06rem;
                    font-size:0.3rem;
                    text-align: center;
                    line-height: 0.68rem;
                    cursor: pointer;
                    color: #fff;
                    margin-top: 0.2rem;
                }
            }
        }

        .pr_box2{
            li{
                width: 50%;
                float: left;
                text-align: center;
                p{
                    font-size:0.44rem;
                    font-weight:400;
                    color:rgba(51,51,51,1);
                }
                div{
                    font-size:0.24rem;
                    color:rgba(187,187,187,1);
                    margin-top: 0.2rem;
                }
            }
        }

        .pr_box3{
            font-size:0.3rem;
            font-weight:400;
            color:rgba(187,187,187,1);
            line-height: 1.1rem;
            height: 1.1rem;
            background: #fff;
            width: 6.3rem;
            margin: 0.2rem auto 0 auto;
            padding: 0 0.3rem;
            cursor: pointer;
            .pr_img1{
                float: left;
                width: 0.6rem;
                margin: 0.25rem 0;
            }
            span{
                font-size:0.36rem;
                font-weight:600;
                color:rgba(25,25,25,0.8);
                margin-left: 0.1rem;
            }
            .pr_img2{
                float: right;
                height: 0.4rem;
                margin: 0.35rem 0;
            }
        }

        .pr_btn{
            width:6rem;
            height:0.88rem;
            margin: 1.2rem auto;
            border:0.01rem solid rgba(247,98,96,1);
            border-radius:0.1rem;

            font-size:0.36rem;
            font-weight:400;
            color:rgba(247,98,96,1);
            text-align: center;
            line-height: 0.88rem;
            cursor: pointer;
        }

        /*推广*/
        .xinyong{
            overflow: hidden;
           padding: 0.2rem;
            li{
                margin: 0.15rem;
                float: left;
                p{
                    font-size:0.32rem;
                    font-weight:400;
                    color:rgba(51,51,51,1);
                    margin-bottom: 0.28rem;
                    padding: 0 0.1rem;
                }
                .xing1{
                    background: url("../img/hy_back1.png") center center no-repeat;
                    background-size: 3.39rem 1.69rem;
                }
                .xing2{
                    background: url("../img/hy_back2.png") center center no-repeat;
                    background-size: 3.39rem 1.69rem;
                    h2{
                        color: #5D94CF;
                    }
                }
                div{
                    overflow: hidden;
                    width:3.22rem;
                    height:1.52rem;
                    background:linear-gradient(90deg,rgba(248,207,139,1),rgba(233,193,128,1));
                    h2{
                        font-size:0.3rem;
                        font-weight:400;
                        color:rgba(190,152,90,1);
                        padding: 0 0.36rem;
                    }
                }
            }
        }
    }
</style>
